package com.xinshujia.controller;

import com.xinshujia.response.RespResult;
import com.xinshujia.service.QuartzService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * *************************************
 * *   @author: 野狼上校               **
 * *   @since: 2024-07-20 17:15       **
 * *   @version: 1.0                  **
 * *************************************
 * <p>
 *     定时任务控制器
 */
@RestController
@RequestMapping("quartz")
public class QuartzController {
    private final QuartzService quartzService;

    public QuartzController(QuartzService quartzService) {
        this.quartzService = quartzService;
    }

    /**
     * 定时任务
     * @param deviceGuid 设备Id
     * @param operateType 操作类型 （0：停止，1：运行）
     */
    @GetMapping("quartzOperate")
    public RespResult quartzOperate(@RequestParam("deviceGuid") String deviceGuid, @RequestParam("operateType") Integer operateType) {
        Boolean flag = quartzService.quartzOperate(deviceGuid, operateType);
        return flag ? RespResult.OK() : RespResult.Fail();
    }
}
